package com.sky.task;

import com.sky.websocket.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @Description: WebSocketTask
 * @Author: Qiuyan
 * @Date: 2025-04-08 09:13
 * @Version： 1.0
 **/

@Component
public class WebSocketTask {

    @Autowired
    private WebSocketServer webSocketServer;

    @Scheduled(cron="0/5 * * * * ?")
    public void sendMessageClient(){
        webSocketServer.sendToAllClient("websocket来自服务端的信息:"+ DateTimeFormatter.ofPattern("HH:mm:ss").format(LocalDateTime.now()));
    }
}
